package com.fadadianqi.mall.web.controller;

import com.fadadianqi.mall.model.Nav;
import com.fadadianqi.mall.service.NavService;
import com.yeqiangwei.commons.util.BeanUtils;
import com.yeqiangwei.commons.util.ValidatorHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller("m_indexControler")
public class IndexController {

    @RequestMapping(value = {"/", "/m"}, method = RequestMethod.GET)
    public String index(HttpServletRequest request, ModelMap modelMap) {
        List<Nav> navItems = navService.showTreeListWithoutIsHidden();
        /*for(Nav item : navItems) {
            NavVO vo = new NavVO();
            BeanUtils.copyProperties(vo, item);
            vo
        }*/
        modelMap.put("navItems", navItems);
        return "/mall/index";
    }

    @Autowired
    private NavService navService;

    public class NavVO extends Nav{

        private Nav rootNav;
        private Nav parentNav;

        public Nav getRootNav() {
            return rootNav;
        }

        public void setRootNav(Nav rootNav) {
            this.rootNav = rootNav;
        }

        public Nav getParentNav() {
            return parentNav;
        }

        public void setParentNav(Nav parentNav) {
            this.parentNav = parentNav;
        }
    }
}
